using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZhuanChang : MonoBehaviour
{
    public Texture[] textures;
    public Texture[] textures1;
    public Texture[] textures2;
    public Texture[] textures3;
    public Material ZhuanChangmaterial;
    public int index=0;
    public Texture[] t;
    Coroutine coroutine_ZhuanChang;
    private void OnEnable()
    {
        switch (index)
        {
            case 0: 
                t = textures;
                break;
            case 1:
                t = textures1;
                break;
            case 2:
                t = textures2;
                break;
            case 3:
                t = textures3;
                break;
        }
        if (coroutine_ZhuanChang != null)
        {
            StopAllCoroutines();
        }
        coroutine_ZhuanChang=StartCoroutine(IE_ZhuanChang(t));
        if (index >= 4)
        {
            index = 0;
        }
        else
        {
            index++;
        }
        
    }
    void Start()
    {
        
    }

    void Update()
    {
        
    }

    IEnumerator IE_ZhuanChang(Texture[] texture)
    {
        for (int i = 0; i < texture.Length; i++)
        {
            ZhuanChangmaterial.SetTexture("_MainTexA", texture[i]);
            yield return new WaitForSeconds(0.03f);
        }
        
    }
}
